﻿using System;
using System.Drawing;
using Graphix.Helpers;
using SvgNet.SvgGdi;

namespace Graphix.Elements
{
    using System.Drawing.Drawing2D;

    public class Line : BaseElement
    {
        #region Implementation of IElement
        public override void Draw(IGraphics graphics)
        {
            graphics.DrawLine(this.Pen, this.XStart, this.YStart, this.XEnd, this.YEnd, this.Attributes);
        }

        public new void Move(float x, float y)
        {
            this.XStart += x;
            this.XEnd += x;
            this.YStart += y;
            this.YEnd += y;
        }
        #endregion

        public float XStart { get; set; }
        public float YStart { get; set; }
        public float XEnd   { get; set; }
        public float YEnd   { get; set; }

        public Pen Pen { get; private set; }

        public Line(float xStart, float yStart, float xEnd, float yEnd, Pen pen)
        {
            this.XStart = xStart;
            this.YStart = yStart;
            this.XEnd = xEnd;
            this.YEnd = yEnd;
            this.Pen = pen;
        }

        public Line(float xStart, float yStart, float xEnd, float yEnd, Color color, string group = null)
            : this(xStart, yStart, xEnd, yEnd, new Pen(color))
        {
            this.Color = new SolidBrush(color);
        }
    }
}
